<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\Cache;
//该函数返回导航栏 栏目 数据
	function get_navbar()
	{
		$nav = model('nav');
		//model 默认查询出来的 结果集为数组，数组中包含对象，我事先已经在model 中 设置了 查询结果集 为 对象，所以这里可以直接用 toArray()来转换结果集
		$navres = $nav->where('nav_isshow=1')->order('nav_index')->select()->toArray();
		return $navres;
	}
//encrypt_openssl新版加密
	function zfencrypt($str,$localIV=OPEN_IV,$encryptKey=OPEN_KEY)
	{
		return openssl_encrypt($str, 'AES-128-CBC',$encryptKey,0,$localIV);
	}
//decrypt_openssl新版解密
	function zfdecrypt($str,$localIV=OPEN_IV,$encryptKey=OPEN_KEY)
	{
		return openssl_decrypt($str, 'AES-128-CBC', $encryptKey, 0, $localIV);
	}
//缓存初始化
	function cache_init()
	{
		$options = [
			// 缓存类型为File
			'type'  =>  'File',
			// 缓存有效期为永久有效
			'expire'=>  0,
			//缓存前缀
			'prefix'=>  'think',
			// 指定缓存目录
			'path'  =>  APP_PATH.'runtime/cache/',
		];
		Cache::connect($options);
	}
